home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / demos / samples / NoteBook.tcl.z / NoteBook.tcl
Encoding:
Text File  |  1999-01-26  |  3.4 KB  |  99 lines

  1. # Tix Demostration Program
  2. #
  3. # This sample program is structured in such a way so that it can be
  4. # executed from the Tix demo program "widget": it must have a
  5. # procedure called "RunSample". It should also have the "if" statment
  6. # at the end of this file so that it can be run as a standalone
  7. # program using tixwish.
  8.  
  9. # This file demonstrates the use of the tixNoteBook widget, which allows
  10. # you to lay out your interface using a "notebook" metaphore
  11. #
  12.  
  13. proc RunSample {w} {
  14.  
  15.     # We use these options to set the sizes of the subwidgets inside the
  16.     # notebook, so that they are well-aligned on the screen.
  17.     #
  18.     set name [tixOptionName $w]
  19.     option add *$name*TixControl*entry.width 10
  20.     option add *$name*TixControl*label.width 18
  21.     option add *$name*TixControl*label.anchor e
  22.  
  23.     # Create the notebook widget and set its backpagecolor to gray.
  24.     # Note that the -backpagecolor option belongs to the "nbframe"
  25.     # subwidget.
  26.     tixNoteBook $w.nb -ipadx 6 -ipady 6
  27.     $w config -bg gray
  28.     $w.nb subwidget nbframe config -backpagecolor gray
  29.  
  30.     # Create the two tabs on the notebook. The -underline option
  31.     # puts a underline on the first character of the labels of the tabs.
  32.     # Keyboard accelerators will be defined automatically according
  33.     # to the underlined character.    
  34.     #
  35.     $w.nb add hard_disk -label "Hard Disk" -underline 0
  36.     $w.nb add network   -label "Network"   -underline 0
  37.     pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top
  38.     
  39.     #----------------------------------------
  40.     # Create the first page
  41.     #----------------------------------------
  42.     set f [$w.nb subwidget hard_disk]
  43.  
  44.     # Create two frames: one for the common buttons, one for the
  45.     # other widgets
  46.     #
  47.     frame $f.f
  48.     frame $f.common
  49.     pack $f.f      -side left  -padx 2 -pady 2 -fill both -expand yes
  50.     pack $f.common -side right -padx 2 -pady 2 -fill y
  51.  
  52.     # Create the controls that only belong to this page
  53.     #
  54.     tixControl $f.f.a -value 12   -label "Access Time: "
  55.     tixControl $f.f.w -value 400  -label "Write Throughput: "
  56.     tixControl $f.f.r -value 400  -label "Read Throughput: "
  57.     tixControl $f.f.c -value 1021 -label "Capacity: "
  58.     pack $f.f.a $f.f.w $f.f.r $f.f.c  -side top -padx 20 -pady 2
  59.  
  60.     # Create the common buttons
  61.     #
  62.     CreateCommonButtons $w $f.common
  63.     
  64.     #----------------------------------------
  65.     # Create the second page    
  66.     #----------------------------------------
  67.     set f [$w.nb subwidget network]
  68.  
  69.     frame $f.f
  70.     frame $f.common
  71.     pack $f.f      -side left  -padx 2 -pady 2 -fill both -expand yes
  72.     pack $f.common -side right -padx 2 -pady 2 -fill y
  73.  
  74.     tixControl $f.f.a -value 12   -label "Access Time: "
  75.     tixControl $f.f.w -value 400  -label "Write Throughput: "
  76.     tixControl $f.f.r -value 400  -label "Read Throughput: "
  77.     tixControl $f.f.c -value 1021 -label "Capacity: "
  78.     tixControl $f.f.u -value 10   -label "Users: "
  79.  
  80.     pack $f.f.a $f.f.w $f.f.r $f.f.c $f.f.u -side top -padx 20 -pady 2
  81.  
  82.     CreateCommonButtons $w $f.common
  83. }
  84.  
  85. proc CreateCommonButtons {w f} {
  86.     button $f.ok     -text OK     -width 6 -command "destroy $w"
  87.     button $f.cancel -text Cancel -width 6 -command "destroy $w"
  88.  
  89.     pack $f.ok $f.cancel -side top -padx 2 -pady 2
  90. }
  91.  
  92. if {![info exists tix_demo_running]} {
  93.     wm withdraw .
  94.     set w .demo
  95.     toplevel $w
  96.     RunSample $w
  97.     bind $w <Destroy> {if {"%W" == ".demo"} exit}
  98. }
  99.